<!-- load ajax page -->
<?php
$items_per_group = 5;
$total_records=$post_record->row()->t_records;
$total_groups = ceil($total_records/$items_per_group);
$uri = $_GET['time']; 
		$nmber_sort = "";
		if ($uri == "one-day-ago") {
			$nmber_sort = 1;
		} else if ($uri == "three-days-ago") {
			$nmber_sort = 3;
		} else if ($uri == "one-week-ago") {
			$nmber_sort = 7;
		}
		
?>
<script type="text/javascript">
	$(document).ready(function() {
	var track_load = 0; //total loaded record group(s)
	var loading  = false; //to prevents multipal ajax loads
	var total_groups = <?php echo $total_groups; ?>; //total record group(s)
	if(total_groups==0){
	$("#results").html(
		'<p class="data_not_found">'
+"សូម​អ​ភ័យ​ទោស​ <br /> ពុំ​មាន​ទិ​ន្ន័យ​បង្ហា​ញ​នោះ​ទេ​ ។​<br /> "+
'<p>');	
	}else{ 
	$('#results').load("<?php echo site_url('tags/get_data_by_search_and_sort_ajax');?>", {'group_no':track_load,'uri_id':<?php echo $nmber_sort; ?>,'uri_tag':"<?php echo $_GET['tag'] ?>"}, function() {
		track_load++;  
	}); 
	$(window).scroll(function() { 
		if($(window).scrollTop() + $(window).height() == $(document).height())  //user scrolled to bottom of the page?
		{
			if(track_load <= total_groups && loading==false) //there's more data to load
			{
				loading = true; //prevent further ajax loading
				$('.animation_image').show(); //show loading image
				//load data from the server using a HTTP POST request
				$.post('<?php echo site_url('tags/get_data_by_search_and_sort_ajax');?>',{'group_no': track_load,'uri_id':<?php echo $nmber_sort; ?>,'uri_tag':"<?php echo $_GET['tag'] ?>"}, function(data){
					$("#results").append(data); //append received data into the element
					//hide loading image
					$('.animation_image').hide(); //hide loading image once data is received
					track_load++; //loaded group increment
					loading = false; 
				}).fail(function(xhr, ajaxOptions, thrownError) { //any errors
					alert(thrownError); //alert with HTTP error
					$('.animation_image').hide(); //hide loading image
					loading = false;
				});
			}
		}
	});
	}
});
</script>
<!-- / end load ajax page -->
<section id="content">
	<!-- Docs page layout -->
	<div id="container" class="transitions-enabled infinite-scroll clearfix">
		<div id="results">
			
		</div>
	</div>
	<!-- #container -->
	<nav id="page-nav">
		
	</nav>
	<div class="animation_image" style="display:none" align="center"><img src="<?php echo base_url().F_IMG; ?>ajax-loader.gif"></div>
</section>

			